package core

import (
	"logengine/model"
	"time"
)

var jsonDataChannel chan model.MessageData = make(chan model.MessageData, 4000)

func CloseMQ() {
	close(jsonDataChannel)
}

func SaveMq(msg model.MessageData) {
	jsonDataChannel <- msg
}

func StartMQ() {
	//
	for {
		select {
		case msg, isOk := <-jsonDataChannel:
			if isOk {
				PostMsg(msg, "csv_data")
			}
			time.Sleep(time.Millisecond * 50)
		}
	}
	//
}
